Skip to content

fix: reduce MCP server status polling frequency#7399

Merged
RC-CHN merged 1 commit intoAstrBotDevs:masterfrom
M1LKT:fix/#7347
Apr 7, 2026
Merged

fix: reduce MCP server status polling frequency#7399
RC-CHN merged 1 commit intoAstrBotDevs:masterfrom
M1LKT:fix/#7347

Conversation

@M1LKT
Copy link
Copy Markdown
Contributor

@M1LKT M1LKT commented Apr 6, 2026

Modifications / 改动点

优化 MCP 服务器列表的状态轮询逻辑。原先 5 秒一次的硬编码轮询过于频繁,且在组件未激活时依然运行。本次改动延长了轮询间隔,并增加了页面可见性检测,以减少不必要的网络请求。

  • This is NOT a breaking change. / 这不是一个破坏性变更。

核心改动:

  • 修改 McpServersSection.vue 中的定时刷新逻辑:

    • 将轮询间隔从 5 秒延长至 30 秒。
    • 优化了组件挂载时的刷新策略,减少冗余请求。
  • 关联 Issue: #7347

修改文件:

Screenshots or Test Results / 运行截图或测试结果

image

Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Reduce unnecessary work and network load by only rendering the active extension tabs and slowing down MCP server status polling.

Enhancements:

  • Render only the currently active extension tab instead of keeping all tabs mounted in the DOM.
  • Increase the MCP servers list auto-refresh interval from 5 seconds to 30 seconds to lessen server and client load.

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Apr 6, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • Consider extracting the 30000 polling interval into a named constant (or config) so it’s easier to tune and keep consistent with any other polling logic in the app.
  • Since the tab content is now controlled via v-if, double‑check that any state that should persist across tab switches is not unintentionally reset on each remount of McpServersSection and other tab components.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider extracting the `30000` polling interval into a named constant (or config) so it’s easier to tune and keep consistent with any other polling logic in the app.
- Since the tab content is now controlled via `v-if`, double‑check that any state that should persist across tab switches is not unintentionally reset on each remount of `McpServersSection` and other tab components.

## Individual Comments

### Comment 1
<location path="dashboard/src/views/ExtensionPage.vue" line_range="165-168" />
<code_context>

           <!-- 指令面板标签页内容 -->
-          <v-tab-item v-show="activeTab === 'components'">
+          <v-tab-item v-if="activeTab === 'components'">
             <div class="mb-4 pt-4 pb-4">
               <div class="d-flex align-center flex-wrap" style="gap: 12px">
</code_context>
<issue_to_address>
**question (bug_risk):** Switching from v-show to v-if changes lifecycle behavior and may reset internal state on each tab switch.

Any internal state within these tab contents (e.g., scroll position, unsaved form data, expanded panels) will now be lost on each tab change. If some tabs need to preserve state, keep those sections on `v-show`, or lift the persistent state into a parent component that isn’t conditionally rendered.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +165 to 168
<v-tab-item v-if="activeTab === 'components'">
<div class="mb-4 pt-4 pb-4">
<div class="d-flex align-center flex-wrap" style="gap: 12px">
<h2 class="text-h2 mb-0">{{ tm("tabs.handlersOperation") }}</h2>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (bug_risk): Switching from v-show to v-if changes lifecycle behavior and may reset internal state on each tab switch.

Any internal state within these tab contents (e.g., scroll position, unsaved form data, expanded panels) will now be lost on each tab change. If some tabs need to preserve state, keep those sections on v-show, or lift the persistent state into a parent component that isn’t conditionally rendered.

@dosubot dosubot bot added the area:webui The bug / feature is about webui(dashboard) of astrbot. label Apr 6, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 7, 2026
@RC-CHN RC-CHN merged commit 42fc16f into AstrBotDevs:master Apr 7, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:webui The bug / feature is about webui(dashboard) of astrbot. lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants